{createStore,compose,applyMiddleware} = require('redux')
thunkMiddleWare = require('redux-thunk').default
#可以使用redux-promise-thunk简化action的创建
promiseMiddleware = require('redux-promise')
tokenPromiseMiddleware = require('../reduxMiddleware/tokenPromiseMiddle.js')

oraState =
  appState:
    active:true
    connected:true
    version:'1.2.2'
  userInfo:
    token:null
    pilotCode:null
    pilotName:null
    pass:null
  menuInfo:
    menuItems:[]
    isLoading:false
  page_inplan:#进口计划
    list:[]
    isLoading:false
    pageIndex:0
    completed:false
    refreshing:false
    lastFetchTime:null
  page_outplan:#出口计划
    list:[]
    isLoading:false
    pageIndex:0
    completed:false
    refreshing:false
    lastFetchTime:null
  page_moveplan:#移泊计划
    list:[]
    isLoading:false
    pageIndex:0
    completed:false
    refreshing:false
    lastFetchTime:null
  page_inattemp:#进口调度
    list:[]
    isLoading:false
    pageIndex:0
    completed:false
    refreshing:false
    lastFetchTime:null
  page_outattemp:#出口调度
    list:[]
    isLoading:false
    pageIndex:0
    completed:false
    refreshing:false
    lastFetchTime:null
  page_moveattemp:#移泊调度
    list:[]
    isLoading:false
    pageIndex:0
    completed:false
    refreshing:false
    lastFetchTime:null
  page_planDetail:#计划调度详情
    modelList:{}
    isLoading:false
    refreshing:false
  page_planPilotInfo:#计划调度详情中的引航员信息
    collections:{}
  page_ckblbg:#船况不良报告
    list:[]
    isLoading:false
    pageIndex:0
    completed:false
    refreshing:false
  page_dddbrz:#调度当班日志
    list:[]
    isLoading:false
    completed:false
    refreshing:false
  page_hdss:#航道水深
    list:[]
    isLoading:false
    pageIndex:0
    completed:false
    refreshing:false
  page_dqdm:#大桥代码
    list:[]
    isLoading:false
    refreshing:false
  page_tz:#通知
    list:[]
    isLoading:false
    pageIndex:0
    completed:false
    lastFetchTime:null
    refreshing:false
    markRead:[]
  page_zygg:#重要公告
    list:[]
    isLoading:false
    pageIndex:0
    completed:false
    lastFetchTime:null
    refreshing:false
    markRead:[]
  page_gd:#规定
    list:[]
    isLoading:false
    pageIndex:0
    completed:false
    lastFetchTime:null
    refreshing:false
  page_yhypm:#引航员排名
    list:[]
    isLoading:false
    pageIndex:0
    completed:false
    lastFetchTime:null
    refreshing:false
    pilotStates:[]
  page_yhygf:#引航员工分
    list:[]
    total:0
    times:0
    isLoading:false
    pageIndex:0
    completed:false
    lastFetchTime:null
    refreshing:false
  page_ygxlxcx:#已公休轮休查询
    list:[]
    isLoading:false
    pageIndex:0
    completed:false
    lastFetchTime:null
    refreshing:false
  page_gcsj:#港车时间
    pilot:
      list:[]
      isLoading:false
      pageIndex:0
      completed:false
      refreshing:false
      lastFetchTime:null
    car:
      list:[]
      isLoading:false
      pageIndex:0
      completed:false
      refreshing:false
      lastFetchTime:null
  page_mt:#浏览码头信息
      list:[]
      isLoading:false
      pageIndex:0
      completed:false
      lastFetchTime:null
      refreshing:false
  page_gxlxsq:
      YLXTS:0
      SYTS:0
      posting:false
      success:false
      error:''
  page_bwss:
      list:[]
      isLoading:false
      pageIndex:0
      completed:false
      lastFetchTime:null
      refreshing:false
  page_yhsj:
      list:{}
      isLoading:false
      completed:false
      lastFetchTime:null
      refreshing:false
  page_hxjg:
      list:[]
      isLoading:false
      completed:false
      lastFetchTime:null
      refreshing:false
  page_ckjl:
      list:[]
      pageIndex:0
      isLoading:false
      completed:false
      lastFetchTime:null
      refreshing:false
  page_yhyqr:
      list:[]
      isLoading:false
      completed:false
      lastFetchTime:null
      refreshing:false
  page_gkcsb:
      list:{}
      isLoading:false
      completed:false
      lastFetchTime:null
      refreshing:false
  page_scdzqz:
      list:[]
      isLoading:false
      completed:false
      lastFetchTime:null
      refreshing:false
  page_pilotInfo:
      pilotInfo:{}
      isLoading:false
      completed:false
      lastFetchTime:null
      refreshing:false


rootReducer = require('../reducers/index.js')
appVersion = oraState.appState.version
initialState = oraState
debugger
if global.appData
   initialState = Object.assign {},oraState,global.appData
initialState.appState.version = appVersion
initialState.page_ckjl = oraState.page_ckjl
#用到了2个中间件
#1.thunkMiddleWare--它使得reducers可以接受一个返回方法的action（否则action必须返回对象）
# 在返回的方法，dispatch被作为参数传入，此时何时触发reducers就可由码农决定了
# 这实现了原始的异步action--因为没有提供任何方便，但拥有最大的自主权
#2.promiseMiddleware--未使用，明天测试
store = createStore rootReducer,initialState,applyMiddleware(tokenPromiseMiddleware,promiseMiddleware,thunkMiddleWare)
module.exports = store
